package pso;


public abstract class BlackBoxFunction {
	private int numEvalutions;
	Point lowerBound, upperBound;

	public BlackBoxFunction(Point lowerBound, Point upperBound) {
		this.lowerBound = lowerBound;
		this.upperBound = upperBound;
		this.numEvalutions = 0;
	}

	public int getNumEvalutions() {
		return numEvalutions;
	}
	
	public double evaluate(Point p){
		/*for(int i = 0; i < p.getDimension(); ++i){
			if(p.getCoordinate(i) < lowerBound.getCoordinate(i)
					|| p.getCoordinate(i) > upperBound.getCoordinate(i)){
				return Double.MAX_VALUE;
			}
		}*/
		numEvalutions++;
		return this.evaluateHelper(p);
		
	}
	
	public Point getUpperBound(){
		return upperBound;
	}
	
	public Point getLowerBound(){
		return lowerBound;
	}

	protected abstract double evaluateHelper(Point p);
}